//
//  CellOfSearch.m
//  ProjectA_ManualGuest
//
//  Created by dingcong on 16/6/30.
//  Copyright © 2016年 丁聪. All rights reserved.
//

#import "CellOfSearch.h"

#import "UIImageView+WebCache.h"
@implementation CellOfSearch

- (void)dealloc{
    
    [_imageOfLeft release];
    [_lableOfRight release];
    [_model release];
    [super dealloc];
    
    
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self creat];
    }
    return self;
}

- (void)creat{
    
    self.imageOfLeft = [[UIImageView alloc]init];
    
//    self.imageOfLeft.backgroundColor = [UIColor purpleColor];
    
    [self.contentView addSubview:self.imageOfLeft];
    
    [self.imageOfLeft mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(0);
        make.leading.equalTo(self.contentView.mas_leading).offset(0);
        make.height.equalTo(self).multipliedBy(1);
        make.width.equalTo(self).multipliedBy(1);
    }];
    
    self.lableOfRight = [[UILabel alloc]init];
    
//    self.lableOfRight.backgroundColor = [UIColor greenColor];
    
    [self.contentView addSubview:self.lableOfRight];
    
    [self.lableOfRight mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.imageOfLeft.mas_centerY);
        
        make.leading.equalTo(self.imageOfLeft.mas_leading).offset(40);
        make.width.offset(SCREEN_WIDTH - 80);
        
    }];
    self.lableOfRight.numberOfLines = 0;
    
    self.lableOfRight.textColor =[UIColor whiteColor];
    self.lableOfRight.textAlignment = NSTextAlignmentCenter;
    [self.lableOfRight release];
    [self.imageOfLeft release];
    
    
}


- (void)setModel:(ModelForSearch *)model{
    
    [self.imageOfLeft sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:nil];
    
    self.lableOfRight.text = model.subject;
    
}
@end
